# 设置 Docker 镜像名称
$dockerImage = "repository-docker.dftianyi.com/guangshi/tylinks-community:0.0.1"

# 获取当前时间戳
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"

Write-Host "start building the project..."

# 执行 Maven 构建
./mvnw clean package -Dmaven.test.skip=true -Dmaven.build.timestamp="$timestamp"

# 检查构建是否成功
Write-Host "project build success!" -ForegroundColor Green

# 切换到 tylinks-standalone 目录
Set-Location ./tylinks-standalone

# 构建 Docker 镜像
Write-Host "start building Docker image: $dockerImage" -ForegroundColor Yellow
docker build -t $dockerImage .

# 检查 Docker 构建结果
if ($LASTEXITCODE -eq 0) {
    Write-Host "Docker imgage build success!" -ForegroundColor Green
}
else {
    Write-Host "Docker imgage build failed!" -ForegroundColor Red
    exit 1
}
